function cmtFocus(strDefault,strName,strValue) {	
	$("#emo_" + strName).show();
	if(strValue.toLowerCase() == strDefault.toLowerCase()) {
		$("#"+strName).val("");
		$("textarea#"+strName).css("min-height","44px");
		$("textarea#"+strName).css("color","#000");
		$("textarea#"+strName).focus();
	}			
}
function cmtBlur(strDefault,strName,strValue,intShow) {
	strValue		= stripTags(strValue);	
	strValue		= strValue.toLowerCase();	
	if(strValue == strDefault.toLowerCase()) {		
		$("#"+strName).val(strDefault);			
		if($.browser.msie) {
			$('#pcontent'+strName).css("min-height","22px");
			$('#pcontent'+strName).css("height","22px");
		} else {
			$('#pcontent'+strName).css("min-height","18px");
			$('#pcontent'+strName).css("height","18px");
		}
		$("textarea#"+strName).css("color","#999");
		if(intShow == 0) $("#emo_" + strName).hide();
	}
	$('.errorMessage').hide();
}
function emoBlur(strDefault,strName,intShow) {
	setTimeout(
			   function(){ 
				   	strValue		= stripTags($('#'+strName).val());	
					strValue		= strValue.toLowerCase();	
					if(strValue == strDefault.toLowerCase() || strValue == "") {	
						$("#"+strName).val(strDefault);			
						if($.browser.msie) {
							$('#pcontent'+strName).css("min-height","22px");
							$('#pcontent'+strName).css("height","22px");
						} else {
							$('#pcontent'+strName).css("min-height","18px");
							$('#pcontent'+strName).css("height","18px");
						}
						$("textarea#"+strName).css("color","#999");
						if(intShow == 0) $("#emo_" + strName).hide();
					}
			   	}
			   	, 100);
}

actionLogin = function() {
	var strEmail 	= $('#pemail').val();	
	var strPass		= $('#ppassword_type').val();
	if(strEmail == "" && strPass == "") {
		alert('Vui lòng nhập thông tin đăng nhập.');
	}
	if(strEmail && strPass) {		
		var postPass = MD5(MD5(strGeneralCode) + MD5(strPass));
		$.cookie('LOGIN_PASS', Base64.encode(Base64.encode(strPass))); 
		$('#ppassword').val(postPass);
		$('#ppassword_type').val('');
		$('#loginForm').submit();
		return true;
	}
	return false;	
}
report = function(intUserId, intId, intType) {
	$.getJSON(				
		HOST_VFRIEND + 'ajax/uireport?uid='+intUserId+'&id='+intId+'&type='+intType+'&callback=?',		
		function(response) {							
			var msg	= response['msg'];			
			if(response['error'] == 0) {				
				$.blockUI({
					message: msg, 
					css: { 
						textAlgin:'left',
						background:'none',
						border: 'none',
						width:'300px', 
						top: (($(window).height()-300)/2) + 'px', 
						left:(($(window).width()-300)/2) + 'px',
						cursor: 'default',
						zIndex: '10001'
					},
					overlayCSS: {
						cursor: 'default',
						zIndex: '10000'
					}
				});
				
			} else {
				alert(msg);
			}
		}
	);
}
if(strMsg) { 
	showUIMessage(strMsg); 
}
if(strError) alert(strError);

notification = function(intAjax,intPage) {
	if(intAjax == undefined) {
		intAjax = 0;
		if(intPage == undefined) intPage = 0;
	} else {
		if(intPage == undefined) intPage = 1;
		if(intAjax == 2) {
			$('#dlgNotification .loading').show();
		}
	}
	$('#liVon').removeClass('von');
	$('#msgVon').html('');
	$('#msgVon').hide();
	$('#msgRequest').html('');
	$('#msgRequest').hide();
	$.getJSON (
		HOST_VFRIEND + 'ajax/notification?aj='+intAjax+'&npage='+intPage+'&callback=?',
		function(response) {
			var msg 	= response['msg']; 
			var error 	= response['error']; 
			if (error == 0) {
				if(intAjax > 0) {	
					$('#dlgNotification .loading').remove();
					if(intAjax == 1)
						$('#cntNotification').html(msg);
					else {
						$('#dlgNotification .more').remove();
						$('#dlgNotification .content').append(msg);
					}
					if($('#scrollNotification') != undefined) {
						$('#scrollNotification').jScrollPane();	
					}
					if(intPage == 1 && intAjax==1) {
						$('#nNotify img').attr('src',HOST_STATICS + 'img/icon/bar-notification.png');					
						$('#numNotification').hide();
					}
				} else {					
					$('#msgNotification').show().html(msg);
				}
			} else {
				alert(msg);
			}
		}
	);
}
closeNotification = function() {
	$('#msgNotification').html('');
	$('#msgNotification').hide();
}
request = function(intAjax, intPage) {
	if(intAjax == undefined) {
		intAjax = 0;
		if(intPage == undefined) intPage = 0;
	} else {
		if(intPage == undefined) intPage = 1;
		if(intAjax == 2) {
			$('#dlgRequest .loading').show();
		}
	}
	$('#liVon').removeClass('von');
	$('#msgVon').html('');
	$('#msgVon').hide();
	$('#msgNotification').html('');
	$('#msgNotification').hide();
	$.getJSON (
		HOST_VFRIEND + 'ajax/request?aj='+intAjax+'&npage='+intPage+'&callback=?',
		function(response) {
			var msg 	= response['msg']; 
			var error	= response['error']; 
			if (error == 0) {
				if(intAjax > 0) {	
					$('#dlgRequest .loading').remove();
					if(intAjax == 1)
						$('#divReContent').html(msg);
					else {
						$('#dlgRequest .more').remove();
						$('#dlgRequest .content').append(msg);
					}
					if($('#scrollRequest') != undefined) {
						$('#scrollRequest').jScrollPane();	
					}
					if(intPage == 1 && intAjax==1) {
						$('#nRequest img').attr('src',HOST_STATICS + 'img/icon/bar-request.png');						
						$('#numRequest').hide();	
					}
				} else {					
					$('#msgRequest').show().html(msg);
				}
			} else {
				alert(msg);
			}
		}
	);
}
closeRequest = function() {
	$('#msgRequest').html('');
	$('#msgRequest').hide();
}
von = function() {
	$('#msgRequest').html('');
	$('#msgRequest').hide('slow');
	$('#msgNotification').html('');
	$('#msgNotification').hide();
	$.getJSON (
		HOST_VFRIEND + 'ajax/von?callback=?',
		function(response) {
			var msg = response['msg']; 
			if (msg) {
				$('#liVon').addClass('von');
				$('#msgVon').html(msg);	
				$('#msgVon').show();
			}
		}
	);
}
closeVon = function() {	
	$('#msgVon').html('');
	$('#msgVon').hide();
	$('#liVon').removeClass('von');
}
getNews = function() {
	$.getJSON (
		HOST_VFRIEND + 'ajax/cnews?callback=?',
		function(response) {
			var intRequest 		= response['request']; 
			var intNotification	= response['notify'];			
			if(intRequest > 0) {
				$('#numRequest').show();
				$('#numRequest strong').html(intRequest);
				$('#nRequest img').attr('src',HOST_STATICS + 'img/icon/bar-request-news.png');
			}
			if(intNotification > 0) {
				$('#numNotification').show();
				$('#numNotification strong').html(intNotification);
				$('#nNotify img').attr('src',HOST_STATICS + 'img/icon/bar-notification-news.png');
			}
		}
	);
}
autoJpForLeft = function() {
	var screenHeight 	= screen.height - 70 - 535;
	var leftColHeight	= $('.leftCol').height();	
	var maxLeft			= 430;
	if(leftColHeight > maxLeft) {
		$('.leftCol #leftNav').jScrollPane();
	}
	$(".leftCol").scrollFixed();
}
$(document).ready(function() {	
	//autoJpForLeft();
	var screenWidth 	= screen.width - 980;
	$('#msgNotification').css('right',((screenWidth/2)+33)+'px');	
	$('#msgRequest').css('right',((screenWidth/2)+2)+'px');
	$('#msgVon').css('left',((screenWidth/2)-20)+'px');
	if(intHexId > 0)
		setInterval('getNews()', 1000*60);//1m
});